﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Data;
using ClassLibrary.Entity;

public partial class Admin_ListAccounts : AdminPage
{
    TblAccountsDAO AccountDAO = new TblAccountsDAO(Global.CONNECTION_STRING);
    TblAlbumImagesDAO AlbumDAO = new TblAlbumImagesDAO(Global.CONNECTION_STRING);
    TblUserGuideDAO UserGuideDAO = new TblUserGuideDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadListUserGuide();
        }
    }

    private void LoadListUserGuide()
    {
        grdListUserGuide.DataSource = UserGuideDAO.GetListUserGuide();
        grdListUserGuide.DataBind();
    }
    
    protected void btnConfirm_Click(object sender, ImageClickEventArgs e)
    {
        bool flag = false;
        try
        {
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE_ADMIN);
        }
        if (flag)
            Response.Redirect("~/Admin/ListUserGuide.aspx");
    }
    protected void btnUpdate_Click(object sender, ImageClickEventArgs e)
    {
        int IDGuide = Convert.ToInt32(((ImageButton)sender).CommandArgument);
        Response.Redirect("~/Admin/UserGuide.aspx?IdGuide=" + IDGuide);
    }
    protected void grdListUserGuide_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            foreach (DataControlFieldCell cell in e.Row.Cells)
            {
                // check all cells in one row
                foreach (Control control in cell.Controls)
                {
                    ImageButton button = control as ImageButton;
                    if (button != null && button.CommandName == "Delete")
                    {
                        // Add delete confirmation
                        //button.CommandArgument = ((TblEmail)e.Row.DataItem).IDEmail.ToString();
                        button.OnClientClick = "if (!confirm('Do you want delete this User Guide?')) return false;";
                    }
                    if (button != null && button.CommandName == "Save")
                    {
                        // Add delete confirmation
                        //button.CommandArgument = ((TblEmail)e.Row.DataItem).IDEmail.ToString();
                        button.OnClientClick = "if (!confirm('Bạn có muốn lưu không?')) return false;";
                    }
                }
            }
        }
    }
    protected void grdListUserGuide_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdListUserGuide.PageIndex = e.NewPageIndex;
        LoadListUserGuide();
    }
}
